package com.esunrising.esungsc.dao;

import com.esunrising.esungsc.entity.BFCustomItem;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

@Repository
public interface BFCustomItemDao extends BaseDao<BFCustomItem>{

    @Query("select t from #{#entityName} t where t.ID = ?1 and t.fiYear = ?2")
    @Transactional(readOnly = true)
    Optional<BFCustomItem> findByKeyWord(String ID, String year);

    @Query("delete from #{#entityName} t where t.ID = ?1 and t.fiYear = ?2")
    @Modifying
    @Transactional(rollbackFor = Exception.class)
    void deleteByKeyWord(String ID, String year);

}
